********************************************************************************
***Joint distribution tables
********************************************************************************

********************************************************************************
***Part A: cash and overdraft normalized by individual-specific, time-invariant average of total expenditures
********************************************************************************


********************************************************************************
*Any individual
********************************************************************************
***Joint distribution table 1
generate byte od_exp_cat=0 if od_exp==0
replace od_exp_cat=1 if od_exp>0 & od_exp<3 
replace od_exp_cat=2 if od_exp>=3 & od_exp<=5 
replace od_exp_cat=3 if od_exp>5 & od_exp<=10 
replace od_exp_cat=4 if od_exp>10 & od_exp<=15 
replace od_exp_cat=5 if od_exp>15 & od_exp != . 

generate byte cons1_cat=0 if cons1==0
replace cons1_cat=1 if cons1>0 & cons1<3
replace cons1_cat=2 if cons1>=3 & cons1<=5
replace cons1_cat=3 if cons1>5 & cons1<=10
replace cons1_cat=4 if cons1>10 & cons1<=15 
replace cons1_cat=5 if cons1>15 & cons1 != .

quietly estpost tabulate od_exp_cat cons1_cat
est store x
esttab x using "Tables/JointDistributionCategories1.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-$<$3" 2 "3-5" 3 "$>$5-10" 4 "$>$10-15" 5 "$>$15") ///
eqlabels("0" "$>$0-$<$3" "3-5" "$>$5-10" "$>$10-15" "$>$15", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
nonumber collabels(none) nostar noobs unstack booktabs
drop cons1_cat od_exp_cat

*Create different categories
generate byte od_exp_cat=0 if od_exp==0
replace od_exp_cat=1 if od_exp>0 & od_exp<=10
replace od_exp_cat=2 if od_exp>10 & od_exp<=20
replace od_exp_cat=3 if od_exp>20 & od_exp<=30
replace od_exp_cat=4 if od_exp>30 & od_exp<=40
replace od_exp_cat=5 if od_exp>40 & od_exp != . 

generate byte cons1_cat=0 if cons1==0
replace cons1_cat=1 if cons1>0 & cons1<=10
replace cons1_cat=2 if cons1>10 & cons1<=20
replace cons1_cat=3 if cons1>20 & cons1<=30
replace cons1_cat=4 if cons1>30 & cons1<=40
replace cons1_cat=5 if cons1>40 & cons1 != .

quietly estpost tabulate od_exp_cat cons1_cat
est store x
esttab x using "Tables/JointDistributionCategories2.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-10" 2 "$>$10-20" 3 "$>$20-30" 4 "$>$30-40" 5 "$>$40") ///
eqlabels("0" "$>$0-10" "$>$10-20" "$>$20-30" "$>$30-40" "$>$40", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
label collabels(none) nonumber nostar noobs unstack booktabs
drop cons1_cat od_exp_cat

*Create different categories
generate byte od_exp_cat3=0 if od_exp==0
replace od_exp_cat3=1 if od_exp>0 & od_exp<=20
replace od_exp_cat3=2 if od_exp>20 & od_exp<=40
replace od_exp_cat3=3 if od_exp>40 & od_exp<=60
replace od_exp_cat3=4 if od_exp>60 & od_exp<=80
replace od_exp_cat3=5 if od_exp>80 & od_exp != . 

generate byte cons1_cat3=0 if cons1==0
replace cons1_cat3=1 if cons1>0 & cons1<=20
replace cons1_cat3=2 if cons1>20 & cons1<=40
replace cons1_cat3=3 if cons1>40 & cons1<=60
replace cons1_cat3=4 if cons1>60 & cons1<=80
replace cons1_cat3=5 if cons1>80 & cons1 != .

quietly estpost tabulate od_exp_cat3 cons1_cat3 
est store x
esttab x using "Tables/JointDistributionCategories3.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-20" 2 "$>$20-40" 3 "$>$40-60" 4 "$>$60-80" 5 "$>$80") ///
eqlabels("0" "$>$0-20" "$>$20-40" "$>$40-60" "$>$60-80" "$>$80", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
collabels(none) nonumber noobs nostar unstack booktabs


**********************************************************
*Table 1: Co-holding in the Baseline Sample
*1A: Coholding in Consumption Days
**********************************************************	
*Create different categories
generate byte od_exp_cat4=0 if od_exp==0
replace od_exp_cat4=1 if od_exp>0 & od_exp<=10
replace od_exp_cat4=2 if od_exp>10 & od_exp<=20
replace od_exp_cat4=3 if od_exp>20 & od_exp<=30
replace od_exp_cat4=4 if od_exp>30 & od_exp != . 

generate byte cons1_cat4=0 if cons1==0
replace cons1_cat4=1 if cons1>0 & cons1<=10
replace cons1_cat4=2 if cons1>10 & cons1<=20
replace cons1_cat4=3 if cons1>20 & cons1<=30
replace cons1_cat4=4 if cons1>30 & cons1 != .

quietly estpost tabulate od_exp_cat4 cons1_cat4 
est store x
esttab x using "Tables/JointDistributionCategories4.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-10" 2 "$>$10-20" 3 "$>$20-30" 4 "$>$30") ///
eqlabels("0" "$>$0-10" "$>$10-20" "$>$20-30" "$>$30", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
collabels(none) nonumber noobs nostar unstack booktabs


********************************************************************************
*Single individual
********************************************************************************
***Joint distribution table 1
generate byte od_exp_cat=0 if od_exp==0 & alwaysin2memberhh==0
replace od_exp_cat=1 if od_exp>0 & od_exp<3 & alwaysin2memberhh==0
replace od_exp_cat=2 if od_exp>=3 & od_exp<=5 & alwaysin2memberhh==0
replace od_exp_cat=3 if od_exp>5 & od_exp<=10 & alwaysin2memberhh==0
replace od_exp_cat=4 if od_exp>10 & od_exp<=15 & alwaysin2memberhh==0
replace od_exp_cat=5 if od_exp>15 & od_exp != . & alwaysin2memberhh==0

generate byte cons1_cat=0 if cons1==0 & alwaysin2memberhh==0
replace cons1_cat=1 if cons1>0 & cons1<3 & alwaysin2memberhh==0
replace cons1_cat=2 if cons1>=3 & cons1<=5 & alwaysin2memberhh==0
replace cons1_cat=3 if cons1>5 & cons1<=10 & alwaysin2memberhh==0
replace cons1_cat=4 if cons1>10 & cons1<=15 & alwaysin2memberhh==0
replace cons1_cat=5 if cons1>15 & cons1 != . & alwaysin2memberhh==0

quietly estpost tabulate od_exp_cat cons1_cat if alwaysin2memberhh==0
est store x
esttab x using "Tables/JointDistributionCategories1_S.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-$<$3" 2 "3-5" 3 "$>$5-10" 4 "$>$10-15" 5 "$>$15") ///
eqlabels("0" "$>$0-$<$3" "3-5" "$>$5-10" "$>$10-15" "$>$15", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
nonumber collabels(none) nostar noobs unstack booktabs
drop od_exp_cat cons1_cat



**********************************************************
*Table A2: Co-holding by Single Individuals
**********************************************************
*Create different categories
generate byte od_exp_cat=0 if od_exp==0 & alwaysin2memberhh==0
replace od_exp_cat=1 if od_exp>0 & od_exp<=10 & alwaysin2memberhh==0
replace od_exp_cat=2 if od_exp>10 & od_exp<=20 & alwaysin2memberhh==0
replace od_exp_cat=3 if od_exp>20 & od_exp<=30 & alwaysin2memberhh==0
replace od_exp_cat=4 if od_exp>30 & od_exp<=40 & alwaysin2memberhh==0
replace od_exp_cat=5 if od_exp>40 & od_exp != .  & alwaysin2memberhh==0

generate byte cons1_cat=0 if cons1==0 & alwaysin2memberhh==0
replace cons1_cat=1 if cons1>0 & cons1<=10 & alwaysin2memberhh==0
replace cons1_cat=2 if cons1>10 & cons1<=20 & alwaysin2memberhh==0
replace cons1_cat=3 if cons1>20 & cons1<=30 & alwaysin2memberhh==0
replace cons1_cat=4 if cons1>30 & cons1<=40 & alwaysin2memberhh==0
replace cons1_cat=5 if cons1>40 & cons1 != . & alwaysin2memberhh==0

quietly estpost tabulate od_exp_cat cons1_cat if alwaysin2memberhh==0
est store x
esttab x using "Tables/JointDistributionCategories2_S.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-10" 2 "$>$10-20" 3 "$>$20-30" 4 "$>$30-40" 5 "$>$40") ///
eqlabels("0" "$>$0-10" "$>$10-20" "$>$20-30" "$>$30-40" "$>$40", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
label collabels(none) nonumber nostar noobs unstack booktabs
drop od_exp_cat cons1_cat

*Create different categories
generate byte od_exp_cat=0 if od_exp==0 & alwaysin2memberhh==0
replace od_exp_cat=1 if od_exp>0 & od_exp<=20 & alwaysin2memberhh==0
replace od_exp_cat=2 if od_exp>20 & od_exp<=40 & alwaysin2memberhh==0
replace od_exp_cat=3 if od_exp>40 & od_exp<=60 & alwaysin2memberhh==0
replace od_exp_cat=4 if od_exp>60 & od_exp<=80 & alwaysin2memberhh==0
replace od_exp_cat=5 if od_exp>80 & od_exp != .  & alwaysin2memberhh==0

generate byte cons1_cat=0 if cons1==0 & alwaysin2memberhh==0
replace cons1_cat=1 if cons1>0 & cons1<=20 & alwaysin2memberhh==0
replace cons1_cat=2 if cons1>20 & cons1<=40 & alwaysin2memberhh==0
replace cons1_cat=3 if cons1>40 & cons1<=60 & alwaysin2memberhh==0
replace cons1_cat=4 if cons1>60 & cons1<=80 & alwaysin2memberhh==0
replace cons1_cat=5 if cons1>80 & cons1 != . & alwaysin2memberhh==0

quietly estpost tabulate od_exp_cat cons1_cat if alwaysin2memberhh==0
est store x
esttab x using "Tables/JointDistributionCategories3_S.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-20" 2 "$>$20-40" 3 "$>$40-60" 4 "$>$60-80" 5 "$>$80") ///
eqlabels("0" "$>$0-20" "$>$20-40" "$>$40-60" "$>$60-80" "$>$80", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
collabels(none) nonumber noobs nostar unstack booktabs
drop od_exp_cat cons1_cat

*Create different categories
generate byte od_exp_cat=0 if od_exp==0 & alwaysin2memberhh==0
replace od_exp_cat=1 if od_exp>0 & od_exp<=10 & alwaysin2memberhh==0
replace od_exp_cat=2 if od_exp>10 & od_exp<=20 & alwaysin2memberhh==0
replace od_exp_cat=3 if od_exp>20 & od_exp<=30 & alwaysin2memberhh==0
replace od_exp_cat=4 if od_exp>30 & od_exp != .  & alwaysin2memberhh==0

generate byte cons1_cat=0 if cons1==0 & alwaysin2memberhh==0
replace cons1_cat=1 if cons1>0 & cons1<=10 & alwaysin2memberhh==0
replace cons1_cat=2 if cons1>10 & cons1<=20 & alwaysin2memberhh==0
replace cons1_cat=3 if cons1>20 & cons1<=30 & alwaysin2memberhh==0
replace cons1_cat=4 if cons1>30 & cons1 != . & alwaysin2memberhh==0

quietly estpost tabulate od_exp_cat cons1_cat if alwaysin2memberhh==0
est store x
esttab x using "Tables/JointDistributionCategories4_S.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-10" 2 "$>$10-20" 3 "$>$20-30" 4 "$>$30") ///
eqlabels("0" "$>$0-10" "$>$10-20" "$>$20-30" "$>$30", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
collabels(none) nonumber noobs nostar unstack booktabs
drop od_exp_cat cons1_cat



**********************************************************
*Table A3: Co-holding by Linked Individuals
**********************************************************
***Joint distribution table 1
generate byte od_exp_cat=0 if od_exp==0 & alwaysin2memberhh==1
replace od_exp_cat=1 if od_exp>0 & od_exp<3 & alwaysin2memberhh==1
replace od_exp_cat=2 if od_exp>=3 & od_exp<=5 & alwaysin2memberhh==1
replace od_exp_cat=3 if od_exp>5 & od_exp<=10 & alwaysin2memberhh==1
replace od_exp_cat=4 if od_exp>10 & od_exp<=15 & alwaysin2memberhh==1
replace od_exp_cat=5 if od_exp>15 & od_exp != . & alwaysin2memberhh==1

generate byte cons1_cat=0 if cons1==0 & alwaysin2memberhh==1
replace cons1_cat=1 if cons1>0 & cons1<3 & alwaysin2memberhh==1
replace cons1_cat=2 if cons1>=3 & cons1<=5 & alwaysin2memberhh==1
replace cons1_cat=3 if cons1>5 & cons1<=10 & alwaysin2memberhh==1
replace cons1_cat=4 if cons1>10 & cons1<=15 & alwaysin2memberhh==1
replace cons1_cat=5 if cons1>15 & cons1 != . & alwaysin2memberhh==1

quietly estpost tabulate od_exp_cat cons1_cat if alwaysin2memberhh==1
est store x
esttab x using "Tables/JointDistributionCategories1_L.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-$<$3" 2 "3-5" 3 "$>$5-10" 4 "$>$10-15" 5 "$>$15") ///
eqlabels("0" "$>$0-$<$3" "3-5" "$>$5-10" "$>$10-15" "$>$15", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
nonumber collabels(none) nostar noobs unstack booktabs
drop od_exp_cat cons1_cat

*Create different categories
generate byte od_exp_cat=0 if od_exp==0 & alwaysin2memberhh==1
replace od_exp_cat=1 if od_exp>0 & od_exp<=10 & alwaysin2memberhh==1
replace od_exp_cat=2 if od_exp>10 & od_exp<=20 & alwaysin2memberhh==1
replace od_exp_cat=3 if od_exp>20 & od_exp<=30 & alwaysin2memberhh==1
replace od_exp_cat=4 if od_exp>30 & od_exp<=40 & alwaysin2memberhh==1
replace od_exp_cat=5 if od_exp>40 & od_exp != .  & alwaysin2memberhh==1

generate byte cons1_cat=0 if cons1==0 & alwaysin2memberhh==1
replace cons1_cat=1 if cons1>0 & cons1<=10 & alwaysin2memberhh==1
replace cons1_cat=2 if cons1>10 & cons1<=20 & alwaysin2memberhh==1
replace cons1_cat=3 if cons1>20 & cons1<=30 & alwaysin2memberhh==1
replace cons1_cat=4 if cons1>30 & cons1<=40 & alwaysin2memberhh==1
replace cons1_cat=5 if cons1>40 & cons1 != . & alwaysin2memberhh==1

quietly estpost tabulate od_exp_cat cons1_cat if alwaysin2memberhh==1
est store x
esttab x using "Tables/JointDistributionCategories2_L.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-10" 2 "$>$10-20" 3 "$>$20-30" 4 "$>$30-40" 5 "$>$40") ///
eqlabels("0" "$>$0-10" "$>$10-20" "$>$20-30" "$>$30-40" "$>$40", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
label collabels(none) nonumber nostar noobs unstack booktabs
drop od_exp_cat cons1_cat

*Create different categories
generate byte od_exp_cat=0 if od_exp==0 & alwaysin2memberhh==1
replace od_exp_cat=1 if od_exp>0 & od_exp<=20 & alwaysin2memberhh==1
replace od_exp_cat=2 if od_exp>20 & od_exp<=40 & alwaysin2memberhh==1
replace od_exp_cat=3 if od_exp>40 & od_exp<=60 & alwaysin2memberhh==1
replace od_exp_cat=4 if od_exp>60 & od_exp<=80 & alwaysin2memberhh==1
replace od_exp_cat=5 if od_exp>80 & od_exp != .  & alwaysin2memberhh==1

generate byte cons1_cat=0 if cons1==0 & alwaysin2memberhh==1
replace cons1_cat=1 if cons1>0 & cons1<=20 & alwaysin2memberhh==1
replace cons1_cat=2 if cons1>20 & cons1<=40 & alwaysin2memberhh==1
replace cons1_cat=3 if cons1>40 & cons1<=60 & alwaysin2memberhh==1
replace cons1_cat=4 if cons1>60 & cons1<=80 & alwaysin2memberhh==1
replace cons1_cat=5 if cons1>80 & cons1 != . & alwaysin2memberhh==1

quietly estpost tabulate od_exp_cat cons1_cat if alwaysin2memberhh==1
est store x
esttab x using "Tables/JointDistributionCategories3_L.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-20" 2 "$>$20-40" 3 "$>$40-60" 4 "$>$60-80" 5 "$>$80") ///
eqlabels("0" "$>$0-20" "$>$20-40" "$>$40-60" "$>$60-80" "$>$80", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
collabels(none) nonumber noobs nostar unstack booktabs
drop od_exp_cat cons1_cat

*Create different categories
generate byte od_exp_cat=0 if od_exp==0 & alwaysin2memberhh==1
replace od_exp_cat=1 if od_exp>0 & od_exp<=10 & alwaysin2memberhh==1
replace od_exp_cat=2 if od_exp>10 & od_exp<=20 & alwaysin2memberhh==1
replace od_exp_cat=3 if od_exp>20 & od_exp<=30 & alwaysin2memberhh==1
replace od_exp_cat=4 if od_exp>30 & od_exp != .  & alwaysin2memberhh==1

generate byte cons1_cat=0 if cons1==0 & alwaysin2memberhh==1
replace cons1_cat=1 if cons1>0 & cons1<=10 & alwaysin2memberhh==1
replace cons1_cat=2 if cons1>10 & cons1<=20 & alwaysin2memberhh==1
replace cons1_cat=3 if cons1>20 & cons1<=30 & alwaysin2memberhh==1
replace cons1_cat=4 if cons1>30 & cons1 != . & alwaysin2memberhh==1

quietly estpost tabulate od_exp_cat cons1_cat if alwaysin2memberhh==1
est store x
esttab x using "Tables/JointDistributionCategories4_L.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-10" 2 "$>$10-20" 3 "$>$20-30" 4 "$>$30") ///
eqlabels("0" "$>$0-10" "$>$10-20" "$>$20-30" "$>$30", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
collabels(none) nonumber noobs nostar unstack booktabs
drop od_exp_cat cons1_cat


**********************************************************
*Table A4: Co-holding by Couples
**********************************************************
***Joint distribution table 1
generate byte od_exp_HH_cat=0 if od_exp_HH==0
replace od_exp_HH_cat=1 if od_exp_HH>0 & od_exp_HH<3 
replace od_exp_HH_cat=2 if od_exp_HH>=3 & od_exp_HH<=5 
replace od_exp_HH_cat=3 if od_exp_HH>5 & od_exp_HH<=10 
replace od_exp_HH_cat=4 if od_exp_HH>10 & od_exp_HH<=15 
replace od_exp_HH_cat=5 if od_exp_HH>15 & od_exp_HH != . 

generate byte cons1_HH_cat=0 if cons1_HH==0
replace cons1_HH_cat=1 if cons1_HH>0 & cons1_HH<3
replace cons1_HH_cat=2 if cons1_HH>=3 & cons1_HH<=5
replace cons1_HH_cat=3 if cons1_HH>5 & cons1_HH<=10
replace cons1_HH_cat=4 if cons1_HH>10 & cons1_HH<=15 
replace cons1_HH_cat=5 if cons1_HH>15 & cons1_HH != .

quietly estpost tabulate od_exp_HH_cat cons1_HH_cat if alwaysin2memberhh==1
est store x
esttab x using "Tables/JointDistributionCategories1_HH.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-$<$3" 2 "3-5" 3 "$>$5-10" 4 "$>$10-15" 5 "$>$15") ///
eqlabels("0" "$>$0-$<$3" "3-5" "$>$5-10" "$>$10-15" "$>$15", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
nonumber collabels(none) nostar noobs unstack booktabs

*Create different categories
generate byte od_exp_HH_cat2=0 if od_exp_HH==0
replace od_exp_HH_cat2=1 if od_exp_HH>0 & od_exp_HH<=10
replace od_exp_HH_cat2=2 if od_exp_HH>10 & od_exp_HH<=20
replace od_exp_HH_cat2=3 if od_exp_HH>20 & od_exp_HH<=30
replace od_exp_HH_cat2=4 if od_exp_HH>30 & od_exp_HH<=40
replace od_exp_HH_cat2=5 if od_exp_HH>40 & od_exp_HH != . 

generate byte cons1_HH_cat2=0 if cons1_HH==0
replace cons1_HH_cat2=1 if cons1_HH>0 & cons1_HH<=10
replace cons1_HH_cat2=2 if cons1_HH>10 & cons1_HH<=20
replace cons1_HH_cat2=3 if cons1_HH>20 & cons1_HH<=30
replace cons1_HH_cat2=4 if cons1_HH>30 & cons1_HH<=40
replace cons1_HH_cat2=5 if cons1_HH>40 & cons1_HH != .

quietly estpost tabulate od_exp_HH_cat2 cons1_HH_cat2 if alwaysin2memberhh==1
est store x
esttab x using "Tables/JointDistributionCategories2_HH.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-10" 2 "$>$10-20" 3 "$>$20-30" 4 "$>$30-40" 5 "$>$40") ///
eqlabels("0" "$>$0-10" "$>$10-20" "$>$20-30" "$>$30-40" "$>$40", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
label collabels(none) nonumber nostar noobs unstack booktabs

*Create different categories
generate byte od_exp_HH_cat3=0 if od_exp_HH==0
replace od_exp_HH_cat3=1 if od_exp_HH>0 & od_exp_HH<=20
replace od_exp_HH_cat3=2 if od_exp_HH>20 & od_exp_HH<=40
replace od_exp_HH_cat3=3 if od_exp_HH>40 & od_exp_HH<=60
replace od_exp_HH_cat3=4 if od_exp_HH>60 & od_exp_HH<=80
replace od_exp_HH_cat3=5 if od_exp_HH>80 & od_exp_HH != . 

generate byte cons1_HH_cat3=0 if cons1_HH==0
replace cons1_HH_cat3=1 if cons1_HH>0 & cons1_HH<=20
replace cons1_HH_cat3=2 if cons1_HH>20 & cons1_HH<=40
replace cons1_HH_cat3=3 if cons1_HH>40 & cons1_HH<=60
replace cons1_HH_cat3=4 if cons1_HH>60 & cons1_HH<=80
replace cons1_HH_cat3=5 if cons1_HH>80 & cons1_HH != .

quietly estpost tabulate od_exp_HH_cat3 cons1_HH_cat3 if alwaysin2memberhh==1
est store x
esttab x using "Tables/JointDistributionCategories3_HH.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-20" 2 "$>$20-40" 3 "$>$40-60" 4 "$>$60-80" 5 "$>$80") ///
eqlabels("0" "$>$0-20" "$>$20-40" "$>$40-60" "$>$60-80" "$>$80", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
collabels(none) nonumber noobs nostar unstack booktabs

*Create different categories
generate byte od_exp_HH_cat4=0 if od_exp_HH==0
replace od_exp_HH_cat4=1 if od_exp_HH>0 & od_exp_HH<=10
replace od_exp_HH_cat4=2 if od_exp_HH>10 & od_exp_HH<=20
replace od_exp_HH_cat4=3 if od_exp_HH>20 & od_exp_HH<=30
replace od_exp_HH_cat4=4 if od_exp_HH>30 & od_exp_HH != . 

generate byte cons1_HH_cat4=0 if cons1_HH==0
replace cons1_HH_cat4=1 if cons1_HH>0 & cons1_HH<=10
replace cons1_HH_cat4=2 if cons1_HH>10 & cons1_HH<=20
replace cons1_HH_cat4=3 if cons1_HH>20 & cons1_HH<=30
replace cons1_HH_cat4=4 if cons1_HH>30 & cons1_HH != .

quietly estpost tabulate od_exp_HH_cat4 cons1_HH_cat4 if alwaysin2memberhh==1
est store x
esttab x using "Tables/JointDistributionCategories4_HH.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-10" 2 "$>$10-20" 3 "$>$20-30" 4 "$>$30") ///
eqlabels("0" "$>$0-10" "$>$10-20" "$>$20-30" "$>$30", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
collabels(none) nonumber noobs nostar unstack booktabs


**********************************************************
*Table 1: Co-holding in the Baseline Sample
*1B: Coholding in Monetary Units (ISK000s)
**********************************************************	
*Different categories
generate byte od_amount_cat=0 if od_amount==0
replace od_amount_cat=1 if od_amount>0 & od_amount<=20000
replace od_amount_cat=2 if od_amount>20000 & od_amount<=40000
replace od_amount_cat=3 if od_amount>40000 & od_amount<=60000
replace od_amount_cat=4 if od_amount>60000 & od_amount<=80000
replace od_amount_cat=5 if od_amount>80000 & od_amount != . 

generate byte cash_cat=0 if cash==0
replace cash_cat=1 if cash>0 & cash<=20000
replace cash_cat=2 if cash>20000 & cash<=40000
replace cash_cat=3 if cash>40000 & cash<=60000
replace cash_cat=4 if cash>60000 & cash<=80000
replace cash_cat=5 if cash>80000 & cash != .

quietly estpost tabulate od_amount_cat cash_cat if edate_id>1334
est store x
esttab x using "Tables/JointDistributionCategories1Nom.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-20?000" 2 "$>$20?000-40?000" 3 "$>$40?000-60?000" 4 "$>$60?000-80?000" 5 "$>$80?000") ///
eqlabels("0" "$>$0-20?000" "$>$20?000-40?000" "$>$40?000-60?000" "$>$60?000-80?000" "$>$80?000", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
label collabels(none) nonumber nostar noobs unstack booktabs ///
substitute(? ,)
drop cash_cat od_amount_cat

*Different categories
generate byte od_amount_cat=0 if od_amount==0
replace od_amount_cat=1 if od_amount>0 & od_amount<=50000
replace od_amount_cat=2 if od_amount>50000 & od_amount<=100000
replace od_amount_cat=3 if od_amount>100000 & od_amount<=150000
replace od_amount_cat=4 if od_amount>150000 & od_amount<=200000
replace od_amount_cat=5 if od_amount>200000 & od_amount != . 

generate byte cash_cat=0 if cash==0
replace cash_cat=1 if cash>0 & cash<=50000
replace cash_cat=2 if cash>50000 & cash<=100000
replace cash_cat=3 if cash>100000 & cash<=150000
replace cash_cat=4 if cash>150000 & cash<=200000
replace cash_cat=5 if cash>200000 & cash != .

quietly estpost tabulate od_amount_cat cash_cat 
est store x
esttab x using "Tables/JointDistributionCategories2Nom.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-50?000" 2 "$>$50?000-100?000" 3 "$>$100?000-150?000" 4 "$>$150?000-200?000" 5 "$>$200?000") ///
eqlabels("0" "$>$0-50?000" "$>$50?000-100?000" "$>$100?000-150?000" "$>$150?000-200?000" "$>$200?000", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
collabels(none) nonumber noobs nostar unstack booktabs ///
substitute(? ,)
drop cash_cat od_amount_cat



**********************************************************
*Table A5: Co-holding by Single Individuals (Monetary Values)
**********************************************************	

***Joint distribution table 1
generate byte od_amount_cat=0 if od_amount==0 & alwaysin2memberhh==0
replace od_amount_cat=1 if od_amount>0 & od_amount<=20000 & alwaysin2memberhh==0
replace od_amount_cat=2 if od_amount>20000 & od_amount<=40000 & alwaysin2memberhh==0
replace od_amount_cat=3 if od_amount>40000 & od_amount<=60000 & alwaysin2memberhh==0
replace od_amount_cat=4 if od_amount>60000 & od_amount<=80000 & alwaysin2memberhh==0
replace od_amount_cat=5 if od_amount>80000 & od_amount != . & alwaysin2memberhh==0

generate byte cash_cat=0 if cash==0 & alwaysin2memberhh==0
replace cash_cat=1 if cash>0 & cash<=20000 & alwaysin2memberhh==0
replace cash_cat=2 if cash>20000 & cash<=40000 & alwaysin2memberhh==0
replace cash_cat=3 if cash>40000 & cash<=60000 & alwaysin2memberhh==0
replace cash_cat=4 if cash>60000 & cash<=80000 & alwaysin2memberhh==0
replace cash_cat=5 if cash>80000 & cash != . & alwaysin2memberhh==0

quietly estpost tabulate od_amount_cat cash_cat if alwaysin2memberhh==0
est store x
esttab x using "Tables/JointDistributionCategories1_SNom.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-20?000" 2 "$>$20?000-40?000" 3 "$>$40?000-60?000" 4 "$>$60?000-80?000" 5 "$>$80?000") ///
eqlabels("0" "$>$0-20?000" "$>$20?000-40?000" "$>$40?000-60?000" "$>$60?000-80?000" "$>$80?000", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
nonumber collabels(none) nostar noobs unstack booktabs ///
substitute(? ,)
drop od_amount_cat cash_cat

*Create different categories
generate byte od_amount_cat=0 if od_amount==0 & alwaysin2memberhh==0
replace od_amount_cat=1 if od_amount>0 & od_amount<=50000 & alwaysin2memberhh==0
replace od_amount_cat=2 if od_amount>50000 & od_amount<=100000 & alwaysin2memberhh==0
replace od_amount_cat=3 if od_amount>100000 & od_amount<=150000 & alwaysin2memberhh==0
replace od_amount_cat=4 if od_amount>150000 & od_amount<=200000 & alwaysin2memberhh==0
replace od_amount_cat=5 if od_amount>200000 & od_amount != .  & alwaysin2memberhh==0

generate byte cash_cat=0 if cash==0 & alwaysin2memberhh==0
replace cash_cat=1 if cash>0 & cash<=50000 & alwaysin2memberhh==0
replace cash_cat=2 if cash>50000 & cash<=100000 & alwaysin2memberhh==0
replace cash_cat=3 if cash>100000 & cash<=150000 & alwaysin2memberhh==0
replace cash_cat=4 if cash>150000 & cash<=200000 & alwaysin2memberhh==0
replace cash_cat=5 if cash>200000 & cash != . & alwaysin2memberhh==0

quietly estpost tabulate od_amount_cat cash_cat if alwaysin2memberhh==0
est store x
esttab x using "Tables/JointDistributionCategories2_SNom.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-50?000" 2 "$>$50?000-100?000" 3 "$>$100?000-150?000" 4 "$>$150?000-200?000" 5 "$>$200?000") ///
eqlabels("0" "$>$0-50?000" "$>$50?000-100?000" "$>$100?000-150?000" "$>$150?000-200?000" "$>$200?000", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
label collabels(none) nonumber nostar noobs unstack booktabs ///
substitute(? ,)
drop od_amount_cat cash_cat



**********************************************************
*Table A6: Co-holding by Linked Individuals (Monetary Values)
**********************************************************	
***Joint distribution table 1
generate byte od_amount_cat=0 if od_amount==0 & alwaysin2memberhh==1
replace od_amount_cat=1 if od_amount>0 & od_amount<=20000 & alwaysin2memberhh==1
replace od_amount_cat=2 if od_amount>20000 & od_amount<=40000 & alwaysin2memberhh==1
replace od_amount_cat=3 if od_amount>40000 & od_amount<=60000 & alwaysin2memberhh==1
replace od_amount_cat=4 if od_amount>60000 & od_amount<=80000 & alwaysin2memberhh==1
replace od_amount_cat=5 if od_amount>80000 & od_amount != . & alwaysin2memberhh==1

generate byte cash_cat=0 if cash==0 & alwaysin2memberhh==1
replace cash_cat=1 if cash>0 & cash<=20000 & alwaysin2memberhh==1
replace cash_cat=2 if cash>20000 & cash<=40000 & alwaysin2memberhh==1
replace cash_cat=3 if cash>40000 & cash<=60000 & alwaysin2memberhh==1
replace cash_cat=4 if cash>60000 & cash<=80000 & alwaysin2memberhh==1
replace cash_cat=5 if cash>80000 & cash != . & alwaysin2memberhh==1

quietly estpost tabulate od_amount_cat cash_cat if alwaysin2memberhh==1
est store x
esttab x using "Tables/JointDistributionCategories1_LNom.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-20?000" 2 "$>$20?000-40?000" 3 "$>$40?000-60?000" 4 "$>$60?000-80?000" 5 "$>$80?000") ///
eqlabels("0" "$>$0-20?000" "$>$20?000-40?000" "$>$40?000-60?000" "$>$60?000-80?000" "$>$80?000", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
nonumber collabels(none) nostar noobs unstack booktabs ///
substitute(? ,)
drop od_amount_cat cash_cat

*Create different categories
generate byte od_amount_cat=0 if od_amount==0 & alwaysin2memberhh==1
replace od_amount_cat=1 if od_amount>0 & od_amount<=50000 & alwaysin2memberhh==1
replace od_amount_cat=2 if od_amount>50000 & od_amount<=100000 & alwaysin2memberhh==1
replace od_amount_cat=3 if od_amount>100000 & od_amount<=150000 & alwaysin2memberhh==1
replace od_amount_cat=4 if od_amount>150000 & od_amount<=200000 & alwaysin2memberhh==1
replace od_amount_cat=5 if od_amount>200000 & od_amount != .  & alwaysin2memberhh==1

generate byte cash_cat=0 if cash==0 & alwaysin2memberhh==1
replace cash_cat=1 if cash>0 & cash<=50000 & alwaysin2memberhh==1
replace cash_cat=2 if cash>50000 & cash<=100000 & alwaysin2memberhh==1
replace cash_cat=3 if cash>100000 & cash<=150000 & alwaysin2memberhh==1
replace cash_cat=4 if cash>150000 & cash<=200000 & alwaysin2memberhh==1
replace cash_cat=5 if cash>200000 & cash != . & alwaysin2memberhh==1

quietly estpost tabulate od_amount_cat cash_cat if alwaysin2memberhh==1
est store x
esttab x using "Tables/JointDistributionCategories2_LNom.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-50?000" 2 "$>$50?000-100?000" 3 "$>$100?000-150?000" 4 "$>$150?000-200?000" 5 "$>$200?000") ///
eqlabels("0" "$>$0-50?000" "$>$50?000-100?000" "$>$100?000-150?000" "$>$150?000-200?000" "$>$200?000", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
label collabels(none) nonumber nostar noobs unstack booktabs ///
substitute(? ,)
drop od_amount_cat cash_cat



**********************************************************
*Table A7: Co-holding by Couples (Monetary Values)
**********************************************************	
***Joint distribution table 1
generate byte od_amount_HH_cat=0 if od_amount_HH==0
replace od_amount_HH_cat=1 if od_amount_HH>0 & od_amount_HH<=20000
replace od_amount_HH_cat=2 if od_amount_HH>20000 & od_amount_HH<=40000 
replace od_amount_HH_cat=3 if od_amount_HH>40000 & od_amount_HH<=60000
replace od_amount_HH_cat=4 if od_amount_HH>60000 & od_amount_HH<=80000
replace od_amount_HH_cat=5 if od_amount_HH>80000 & od_amount_HH != . 

generate byte cash_HH_cat=0 if cash_HH==0
replace cash_HH_cat=1 if cash_HH>0 & cash_HH<=20000
replace cash_HH_cat=2 if cash_HH>20000 & cash_HH<=40000
replace cash_HH_cat=3 if cash_HH>40000 & cash_HH<=60000
replace cash_HH_cat=4 if cash_HH>60000 & cash_HH<=80000
replace cash_HH_cat=5 if cash_HH>80000 & cash_HH != .

quietly estpost tabulate od_amount_HH_cat cash_HH_cat if alwaysin2memberhh==1
est store x
esttab x using "Tables/JointDistributionCategories1_HHNom.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-20?000" 2 "$>$20?000-40?000" 3 "$>$40?000-60?000" 4 "$>$60?000-80?000" 5 "$>$80?000") ///
eqlabels("0" "$>$0-20?000" "$>$20?000-40?000" "$>$40?000-60?000" "$>$60?000-80?000" "$>$80?000", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
nonumber collabels(none) nostar noobs unstack booktabs ///
substitute(? ,)
drop cash_HH_cat od_amount_HH_cat

*Create different categories
generate byte od_amount_HH_cat=0 if od_amount_HH==0
replace od_amount_HH_cat=1 if od_amount_HH>0 & od_amount_HH<=50000
replace od_amount_HH_cat=2 if od_amount_HH>50000 & od_amount_HH<=100000
replace od_amount_HH_cat=3 if od_amount_HH>100000 & od_amount_HH<=150000
replace od_amount_HH_cat=4 if od_amount_HH>150000 & od_amount_HH<=200000
replace od_amount_HH_cat=5 if od_amount_HH>200000 & od_amount_HH != . 

generate byte cash_HH_cat=0 if cash_HH==0
replace cash_HH_cat=1 if cash_HH>0 & cash_HH<=50000
replace cash_HH_cat=2 if cash_HH>50000 & cash_HH<=100000
replace cash_HH_cat=3 if cash_HH>100000 & cash_HH<=150000
replace cash_HH_cat=4 if cash_HH>150000 & cash_HH<=200000
replace cash_HH_cat=5 if cash_HH>200000 & cash_HH != .

quietly estpost tabulate od_amount_HH_cat cash_HH_cat if alwaysin2memberhh==1
est store x
esttab x using "Tables/JointDistributionCategories2_HHNom.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-50?000" 2 "$>$50?000-100?000" 3 "$>$100?000-150?000" 4 "$>$150?000-200?000" 5 "$>$200?000") ///
eqlabels("0" "$>$0-50?000" "$>$50?000-100?000" "$>$100?000-150?000" "$>$150?000-200?000" "$>$200?000", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
label collabels(none) nonumber nostar noobs unstack booktabs ///
substitute(? ,)

drop cash_HH_cat od_amount_HH_cat


********************************************************************************
********************************************************************************
********************************************************************************
***Joint distribution tables for non-credit-card holders vs. credit-card-holders


***Joint distribution table for non-credit-card-holder
generate byte od_exp_cat=0 if od_exp==0 & ccard_pers == 0
replace od_exp_cat=1 if od_exp>0 & od_exp<3 & ccard_pers == 0 
replace od_exp_cat=2 if od_exp>=3 & od_exp<=5 & ccard_pers == 0
replace od_exp_cat=3 if od_exp>5 & od_exp<=10 & ccard_pers == 0
replace od_exp_cat=4 if od_exp>10 & od_exp<=15 & ccard_pers == 0 
replace od_exp_cat=5 if od_exp>15 & od_exp != . & ccard_pers == 0 

generate byte cons1_cat=0 if cons1==0 & ccard_pers == 0 
replace cons1_cat=1 if cons1>0 & cons1<3 & ccard_pers == 0 
replace cons1_cat=2 if cons1>=3 & cons1<=5 & ccard_pers == 0 
replace cons1_cat=3 if cons1>5 & cons1<=10 & ccard_pers == 0 
replace cons1_cat=4 if cons1>10 & cons1<=15 & ccard_pers == 0 
replace cons1_cat=5 if cons1>15 & cons1 != . & ccard_pers == 0 

quietly estpost tabulate od_exp_cat cons1_cat if ccard_pers==0
est store x
esttab x using "Tables/JointDistributionCategories1_NoCcard.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-$<$3" 2 "3-5" 3 "$>$5-10" 4 "$>$10-15" 5 "$>$15") ///
eqlabels("0" "$>$0-$<$3" "3-5" "$>$5-10" "$>$10-15" "$>$15", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
nonumber collabels(none) nostar noobs unstack booktabs
drop cons1_cat od_exp_cat

***Joint distribution table for credit-card-holder
generate byte od_exp_cat=0 if od_exp==0 & ccard_pers == 1
replace od_exp_cat=1 if od_exp>0 & od_exp<3 & ccard_pers == 1
replace od_exp_cat=2 if od_exp>=3 & od_exp<=5 & ccard_pers == 1
replace od_exp_cat=3 if od_exp>5 & od_exp<=10 & ccard_pers == 1
replace od_exp_cat=4 if od_exp>10 & od_exp<=15 & ccard_pers == 1 
replace od_exp_cat=5 if od_exp>15 & od_exp != . & ccard_pers == 1 

generate byte cons1_cat=0 if cons1==0 & ccard_pers == 1 
replace cons1_cat=1 if cons1>0 & cons1<3 & ccard_pers == 1 
replace cons1_cat=2 if cons1>=3 & cons1<=5 & ccard_pers == 1 
replace cons1_cat=3 if cons1>5 & cons1<=10 & ccard_pers == 1 
replace cons1_cat=4 if cons1>10 & cons1<=15 & ccard_pers == 1
replace cons1_cat=5 if cons1>15 & cons1 != . & ccard_pers == 1 

quietly estpost tabulate od_exp_cat cons1_cat if ccard_pers==1
est store x
esttab x using "Tables/JointDistributionCategories1_Ccard.tex", replace ///
mtitle("Cash holdings") ///
rename(1 "$>$0-$<$3" 2 "3-5" 3 "$>$5-10" 4 "$>$10-15" 5 "$>$15") ///
eqlabels("0" "$>$0-$<$3" "3-5" "$>$5-10" "$>$10-15" "$>$15", lhs("Overdraft holdings")) ///
cells("pct(fmt(2))") ///
nonumber collabels(none) nostar noobs unstack booktabs
drop cons1_cat od_exp_cat


**********************************************************
*Table A13: Age across the Joint Distribution of Overdraft and Cash Holdings
*Table A14: Female across the Joint Distribution of Overdraft and Cash Holdings
*Table A15: Permanent Income across the Joint Distribution of Overdraft and Cash Holdings
*Table A16: Couple across the Joint Distribution of Overdraft and Cash Holdings
**********************************************************
drop if new_ind_id==11548|new_ind_id==4821|new_ind_id==388|new_ind_id==2315 // eliminate abnormal data points with exceptionally high income
gen income_dis = month_total_income_mean/1000000 

// Generate groups
gen od_group = .
gen cons_group = .

// Overdraft groups
replace od_group = 1 if od_exp == 0
replace od_group = 2 if od_exp > 0 & od_exp <= 10
replace od_group = 3 if od_exp > 10 & od_exp <= 20
replace od_group = 4 if od_exp > 20 & od_exp <= 30
replace od_group = 5 if od_exp > 30

// Cash groups
replace cons_group = 1 if cons1 == 0
replace cons_group = 2 if cons1 > 0 & cons1 <= 10
replace cons_group = 3 if cons1 > 10 & cons1 <= 20
replace cons_group = 4 if cons1 > 20 & cons1 <= 30
replace cons_group = 5 if cons1 > 30
foreach var in age female income_dis alwaysin2memberhh{
	preserve
	// Calculate the mean and standard deviation in each category group
	collapse (mean) `var'_mean = `var' (sd) `var'_sd = `var' if od_group != . & cons_group != ., by(od_group cons_group)

	// Export the result to excel 
	export excel using "`var'.xlsx", firstrow(variables) replace
	restore
}